<#import "/base/baseUrl.html" as baseUrl>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <!-- 页面通用jsCSS -->
    <#include "/base/baseJs.html"/>
</head>
<body>

<div class="er-content">
    <fieldset class="layui-elem-field layui-field-title" style="">
        <legend>修改密码</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" id="form">
        <div class="layui-form-item">
            <label class="layui-form-label">当前密码</label>
            <div class="layui-input-inline">
                <input type="password" name="oldPassword" lay-verify="required" lay-verType="tips"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="pass" lay-verType="tips"
                       autocomplete="off" id="LAY_password" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="repassword" lay-verify="repass" lay-verType="tips"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="er-btn-div">
            <button class="layui-btn" lay-submit lay-filter="fromSubmit">确认修改</button>
        </div>
    </form>
</div>


<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form;

        //监听提交
        form.on('submit(fromSubmit)', function (data) {
            /* 加载层 */
            $.post("${domain}/editPassword", data.field, function (data, status) {
                if (data.code != 200) {
                    layer.alert('修改密码失败: ' + data.msg, {icon: 5});
                    layer.close();
                } else {
                    top.window.layer.alert('修改密码成功', {
                        icon: 1, yes: function (index, layero) {
                            top.window.layer.closeAll();
                           top.window.location.href="${domain}/login/logout"
                        }
                    })
                }
            });
            return false;
        });
    });
</script>
</body>
</html>